import 'package:get/get.dart';

import '../../../data/model/uer_info.dart';
import '../../../service/dio_service.dart';
import '../../../util/dio/app_response.dart';

class OtherProfileController extends GetxController {
  DioService _dioService = Get.find();
  Rx<UserInfo> userInfo = new UserInfo().obs;

  num friendId = 0;


  Future<void> getUserInfo() async {
    if (friendId == 0) {
      return;
    }
    AppResponse res =
    await _dioService.get("/user", queryParameters: {'id': friendId});
    if (res.ok) {
      userInfo.value = UserInfo.fromJson(res.data);
    }
  }

  @override
  void onInit() {
    print('进入id: ' + Get.arguments.toString() + "的个人profile页面");
    friendId = Get.arguments;
    getUserInfo();
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {}
}
